

* Open data
use "WLS_Exp.dta", replace

* Covariates macro
global covars = "gender_female_imp age_30_44_imp age_45_64_imp age_65plus_imp degree_imp interested_imp gevote20192_imp"




*******************************
** TABLE 1: SAMPLE DESCRIPTIVES
*******************************

* Means & t-tests
foreach var of varlist gender_female age_below30 age_30_44 age_45_64 age_65plus degree gevote2019_LAB gevote2019_CON gevote2019_PLAID gevote2019_LIBDEM  gevote2019_OTH gevote2019_DIDNOTVOTE {
di "`var'"
ttest `var' if pickone_voter == 1, by(treated)
}

* Total N
tab treated if pickone_voter == 1





******************************
** TABLE 2: REGRESSION RESULTS
******************************

* Cap candidate rank at 5 for better visiblity
gen rank_cand_capped = rank_cand
replace rank_cand_capped = 5 if inrange(rank_cand,6,10)


* Model 1: PTVs & all candidates
reg ptv i.treated##ib5.rank_cand_capped $covars i.cid, cl(id)
estimates store m1

* Model 2: PTVs & participating candidates
reg ptv i.treated##ib5.rank_cand_capped $covars i.cid if cparticipated == 1, cl(id)
estimates store m2

* Model 3: PTVs & non-participating candidates
reg ptv i.treated##ib5.rank_cand_capped $covars i.cid if cparticipated == 0, cl(id)
estimates store m3

* Model 4: Vote intention & all candidates
reg voteint_cand i.treated##ib5.rank_cand_capped $covars i.cid, cl(id)
estimates store m4

* Model 5: Vote intention & participating candidates
reg voteint_cand i.treated##ib5.rank_cand_capped $covars i.cid if cparticipated == 1, cl(id)
estimates store m5

* Model 6: Vote intention & non-participating candidates
reg voteint_cand i.treated##ib5.rank_cand_capped $covars i.cid if cparticipated == 0, cl(id)
estimates store m6





*****************************
** FIGURE 2: MARGINAL EFFECTS
*****************************

* Note: First estimate the above regression models 

qui: do "Marginal_Effects.do"





****************************************************
** ADDITIONAL RESULTS AND STATISTICS RPORTED IN TEXT
****************************************************

* Response rate in candidate survey
preserve
use "WLS_Complete.dta", replace // This version of the dataset also includes VAA users that were not exposed to one of the two experimental conditions analyzed in the paper
	* Number of candidates who participated in the candidate survey
	tab cparticipated if pickone_candidate == 1 // 85 (out of 309 in total = 28%)
		* Note: only 261 candidates were included in the VAA. This is because independent candidates who did not participate in the candidate survey could not be included in the VAA (there was no party position we could have used for imputation)
	* Candidate response rate among top 4 parties
	tab cparticipated if inrange(party,1,4) & pickone_candidate == 1 // 59 out of 160 = 37%
restore

* Number of VAA users who answered at least one PTV question
tab completed_ptvs if pickone_voter == 1

* Probability of VAA users indicating they intend to vote for top-ranked candidate in the two experimental conditions
	* Note: First estimate the above regression models 
forvalues i = 4(1)6 {
estimates restore m`i'
margins, at(treated = (0(1)1) rank_cand_capped = (1)) 
}

